<?php
//
//-------------------------------------------------
// | CreateTime: 2020/8/27 16:54
//+------------------------------------------------
// | Author: chenxueyuan
//+------------------------------------------------
// | Describe: ...
//+------------------------------------------------

namespace app\admin\controller;


use think\Controller;

class Login extends Controller
{
    public function index(){
        return view();
    }
    public function checkLogin(){
        if($this->request->isPost())
        {
        $post=$this->request->post();
        $admin_find=db('admin')->where("name",$post['name'])->where("password",md5($post['password']))->find();
        if ($admin_find){
            session('adminId',$admin_find['id']);
            session('adminName',$admin_find['name']);
            $this->success('登录成功','admin/index/index');
        }else{
            $this->error('用户名或者密码错误','admin/login/index');
        }
        }else{
            $this->redirect('admin/login');
        }
        return view();
    }
    public function Logout(){
        session('adminId',null);
        session('adminName',null);
        $this->success('退出成功，请重新登录','admin/login/index');
    }
}